<?php
/**
 *  在线留言控制器
 */
class MessageController extends Controller
{
	/**
	 * 首页
	 */
	public function actionIndex()
	{
		$id=intval($_GET['id']);
		$lang=$this->getLang();
		if($lang=='en'){
			$this->pageTitle='Message'.$this->public_title['en'];
		}else{
			$this->pageTitle='在线留言'.$this->public_title['cn'];
		}
		$this->render('message/index',array('lang'=>$lang));
	}


	/**
	 *ajax方式新增留言
     */
	public function actionAjaxMessage(){
		$lang=$this->getLang();
		if($lang=='en'){
			$retData = array('code' => '200' ,'msg' => 'Message success');
		}else{
			$retData = array('code' => '200' ,'msg' => '留言成功');
		}
		$body=fzr($_POST['body']);
		$name=fzr($_POST['name']);
		$email=fzr($_POST['email']);
		$phone=fzr($_POST['phone']);

		if(empty($email) && empty($phone)){
			if($lang=='en'){
				echo_json_exitc(array('code'=>'500','msg'=>'Please fill in the contact information!'));
			}else{
				echo_json_exitc(array('code'=>'500','msg'=>'联系方式为空'));
			}
		}

		$model=new message_info();
		$model->body=$body;
		$model->name=$name;
		$model->phone=$phone;
		$model->email=$email;
		$model->time=time();
		$model->save();

		echo_json_exitc($retData);

	}












}